﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UCL.Forms.Components
{
    /// <summary>
    /// 文件选择对话框
    /// </summary>
    /// <remarks>2014-4-24 1.0 by sutroon</remarks>
    [ToolboxBitmap(typeof(TextBox))]
    public partial class FileBrowserField : UserControl
    {
        public string LabelText { get { return lblTitle.Text; } set { lblTitle.Text = value; } }

        /// <summary>
        /// 获取或设置文件类型筛选器
        /// </summary>
        public string FileFilter { get; set; }

        /// <summary>
        /// 获取或设置文件名
        /// </summary>
        public string FileName { get { return tbPath.Text; } set { tbPath.Text = value; } }
        public FileBrowserField()
        {
            InitializeComponent();
            btnBrowser.Click += btnBrowser_Click;
        }
        protected void btnBrowser_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (!string.IsNullOrEmpty(FileFilter)) ofd.Filter = FileFilter;
            if (DialogResult.OK != ofd.ShowDialog()) return;
            tbPath.Text = ofd.FileName;
        }
    }
}
